package com.ucar.train.service.zhoujinmu.utils;

/**
 * @author zhoujinmu
 * @title ResponseEntity
 * @projectName train-parent
 * @description TODO
 * @created 2019-08-22 16:57
 **/
public class ResponseEntity<T> {

    private static final String CODE_SUCCESS = "执行成功";

    private static final String CODE_FAIL = "执行失败";

    private static final String CODE_RECONNECT = "重新连接";

    private String code;
    private T data;
    private String msg;

    public ResponseEntity(){

    }

    public ResponseEntity(String code){
        this.code = code;
    }

    public ResponseEntity(String code, T data){
        this.code = code;
        this.data = data;
    }

    public ResponseEntity(String code, String msg){
        this.code = code;
        this.msg = msg;
    }

    public static ResponseEntity success(){
        return new ResponseEntity(CODE_SUCCESS);
    }

    public static ResponseEntity success(Object data){
        return new ResponseEntity(CODE_SUCCESS, data);
    }

    public static ResponseEntity fail(String msg){
        return new ResponseEntity(CODE_FAIL, msg);
    }

    public static ResponseEntity widthCode(String errorCode) {
        return new ResponseEntity(errorCode);
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }
}

